package com.pine.app.module.security.oauth.config;

import com.google.common.collect.Lists;
import com.pine.app.module.security.core.web.IWebFilterDef;
import com.pine.app.module.security.oauth.handler.FrameworkEndpointHandlerMapping;
import com.pine.app.module.security.oauth.plugin.ProcessPlugin;
import com.pine.app.module.security.oauth.provider.AuthenticationManager;
import com.pine.app.module.security.oauth.provider.authrizationCode.AuthenticationCodeStore;
import com.pine.app.module.security.oauth.provider.client.ClientDetailsService;
import com.pine.app.module.security.oauth.provider.token.store.TokenStore;

import java.util.List;

/**
 * @author xiaoyuan
 * @create 2020/3/25 13:48
 **/
public class AuthorizationServerConfigurer {

    private TokenStore tokenStore;
    private AuthenticationManager authenticationManager;
    private ClientDetailsService clientDetailsService;
    private FrameworkEndpointHandlerMapping frameworkEndpointHandlerMapping;

    private AuthenticationCodeStore authenticationCodeStore;

    private List<ProcessPlugin> plugins = Lists.newArrayList();

    private List<IWebFilterDef> filterDefs = Lists.newArrayList();


    public TokenStore getTokenStore() {
        return tokenStore;
    }

    public AuthenticationManager getAuthenticationManager() {
        return authenticationManager;
    }

    public ClientDetailsService getClientDetailsService() {
        return clientDetailsService;
    }

    public FrameworkEndpointHandlerMapping getFrameworkEndpointHandlerMapping() {
        return frameworkEndpointHandlerMapping;
    }

    public AuthenticationCodeStore getAuthenticationCodeStore() {
        return authenticationCodeStore;
    }


    public List<ProcessPlugin> getPlugins() {
        return plugins;
    }

    public List<IWebFilterDef> getFilterDefs() {
        return filterDefs;
    }

    public AuthorizationServerConfigurer tokenStore(TokenStore tokenStore) {

        this.tokenStore = tokenStore;
        return this;
    }

    public AuthorizationServerConfigurer authenticationManager(AuthenticationManager authenticationManager) {
        this.authenticationManager = authenticationManager;
        return this;
    }

    public AuthorizationServerConfigurer clientDetailsService(ClientDetailsService clientDetailsService) {
        this.clientDetailsService = clientDetailsService;
        return this;

    }

    public AuthorizationServerConfigurer frameworkEndpointHandlerMapping(FrameworkEndpointHandlerMapping frameworkEndpointHandlerMapping) {
        this.frameworkEndpointHandlerMapping = frameworkEndpointHandlerMapping;
        return this;
    }

    public AuthorizationServerConfigurer authenticationCodeStore(AuthenticationCodeStore authenticationCodeStore) {
        this.authenticationCodeStore = authenticationCodeStore;
        return this;
    }

    public AuthorizationServerConfigurer addPlugs(ProcessPlugin processPlugin) {
        this.plugins.add(processPlugin);
        return this;

    }

    public AuthorizationServerConfigurer addFilter(IWebFilterDef filterDef) {
        this.filterDefs.add(filterDef);
        return this;

    }
}
